/****************************************************************
Compile: gcc -O3 -o check main.c check2.c

This program is used to check the feasibility for a given trajectory under consistant threshold rules.
****************************************************************/

#include <stdio.h>
#include <stdlib.h>

extern int network_inferred (int N, int L, int pathway[L][N], int mode1, int mode2);

void print_help ()
{
	printf ("Usage         : ./check mode1 mode2 N L inputfile\n");
	printf ("                (./check 0 0 10 11 Budding1.txt)\n");
	printf ("mode1         : 0 No self-degradation and self-activation; 1 Allow self-degradation; 2 Allow self-degradation and self-activation\n");
	printf ("mode2         : 0 No Restrictions ; 1 Restriction I ; 2 Restriction II; 3 Restriction I and II\n");
	printf ("N             : number of the nodes\n");
	printf ("L             : number of the steps\n\n");
}

int main (int argc, char *argv[])
{
	int i, j, N, L, mode1, mode2, flag;
	FILE *fp;
	char buf[256];

	if (argc == 1)
	{
		print_help ();
		exit (0);
	}

	mode1 = atoi (argv[1]);
	mode2 = atoi (argv[2]);
	N = atoi (argv[3]);
	L = atoi (argv[4]);

	int pathway[L][N];

	fp = fopen (argv[5], "r");
	while (fgets (buf, 256, fp))
	{
		for (i = 0; i < L; i++)
		{
			for (j = 0; j < N; j++)
			{
				fscanf (fp, "%d", &pathway[i][j]);
			}
			fgets (buf, 256, fp);
		}

		flag = network_inferred (N, L, pathway, mode1, mode2);
		if (flag == 0)
			continue;

		printf ("c consistant threshold process\n");
		for (i = 0; i < L; i++)
		{
			for (j = 0; j < N; j++)
			{
				printf ("%d ", pathway[i][j]);
			}
			printf ("\n");
		}
	}
	fclose (fp);
}
